﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL
{
    public class ePioneer_Lecturer
    {
        private readonly DAL.ePioneer_Lecturer dal = new DAL.ePioneer_Lecturer();
        public ePioneer_Lecturer()
        { }
        #region  Method

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.ePioneer_Lecturer model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.ePioneer_Lecturer model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string Idlist)
        {
            return dal.DeleteList(Idlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.ePioneer_Lecturer GetModel(string lecturer)
        {
            return dal.GetModel(lecturer);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.ePioneer_Lecturer> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.ePioneer_Lecturer> DataTableToList(DataTable dt)
        {
            List<Model.ePioneer_Lecturer> modelList = new List<Model.ePioneer_Lecturer>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ePioneer_Lecturer model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ePioneer_Lecturer();
                    if (dt.Rows[n]["Id"] != null && dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["Lecturer"] != null && dt.Rows[n]["Lecturer"].ToString() != "")
                    {
                        model.Lecturer = dt.Rows[n]["Lecturer"].ToString();
                    }
                    if (dt.Rows[n]["BriefInfo"] != null && dt.Rows[n]["BriefInfo"].ToString() != "")
                    {
                        model.BriefInfo = dt.Rows[n]["BriefInfo"].ToString();
                    }
                    if (dt.Rows[n]["PicUrl"] != null && dt.Rows[n]["PicUrl"].ToString() != "")
                    {
                        model.PicUrl = dt.Rows[n]["PicUrl"].ToString();
                    }
                    if (dt.Rows[n]["Location"] != null && dt.Rows[n]["Location"].ToString() != "")
                    {
                        model.Location = dt.Rows[n]["Location"].ToString();
                    }
                    if (dt.Rows[n]["Speciality"] != null && dt.Rows[n]["Speciality"].ToString() != "")
                    {
                        model.Speciality = dt.Rows[n]["Speciality"].ToString();
                    }
                    
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        #endregion  Method
    }
}
